<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
	<title>用户注册</title>
</head>
<body>
    <a href="table2.php">用户注册</a>
    <table border="1" width="600px">
    	<tr>
    	  <th>id</th>
    	  <th>邮箱</th>	
    	  <th>用户名</th>	
    	  <th>年龄</th>		
    	  <th>出生日期</th>	
    	  <th>性别</th>	
    	  <th>课程</th>
    	  <th>操作</th>		
    	</tr>
    
    <?php
      $conn=mysqli_connect('localhost','root','123456');
      mysqli_select_db($conn,'usermessage');
      $sql='select id,email,username,year(now())-year(brithday) as age,brithday,gender,couress from user';
      $result=mysqli_query($conn,$sql);
      $data=[];
      while ($row=mysqli_fetch_array($result)) {
      	$row['gender']=$row['gender']==1?'男':'女';
      	$data[]=$row;
      }
      mysqli_close($conn);
    ?>
    <?php foreach ($data as $row):?>
       <tr>
       	<td><?= $row['id']?></td>
       	<td><?= $row['email']?></td>
       	<td><?= $row['username']?></td>
       	<td><?= $row['age']?></td>
       	<td><?= $row['brithday']?></td>
       	<td><?= $row['gender']?></td>
       	<td><?= $row['couress']?></td>
       	<td><a href="action/delete.php?id=<?=$row['id'] ?>" >删除</a></td>
       </tr>
    <?php endforeach;  ?>
    </table>
</body>
</html>